<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">

    <title>Title</title>
    <link rel="stylesheet" th:href="@{/src/css/layui.css}">

</head>
<body>
<form class="layui-form">
   <!-- <input th:type="text" name="email"/>
    <input th:type="text" name="vercode"/>

    <input th:type="submit" th:value="提交">-->
    <div class="layui-form-item">
    <label class="layui-form-label">邮箱</label>
    <div class="layui-input-block">
        <input type="text" id="email" class="layui-input"
               placeholder="邮箱" name="email" value=""
               lay-verify="email">

    </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">验证码</label>
        <div class="layui-input-block">
            <input type="text" id="vercode" class="layui-input"
                   placeholder="验证码" name="vercode" value=""
                   lay-verify="required">

        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="addUser">立即提交</button>
        </div>
    </div>


</form>
</body>
<script th:src="@{/src/layui.js}"></script>
<script>

    layui.use(['form','layer','jquery'],function () {
        var form = layui.form,

            $ = layui.jquery,
            layer = layui.layer;


        //添加
        form.on('submit(addUser)',function (data) {

            var email=data.field.email;
            var  vercode=data.field.vercode;
            layer.msg(email);
            $.ajax({
                url:'/isCode?email='+email+'&&vercode='+vercode,
                type:'post',
                data:data.field,
                dataType:'json',
                success:function (res) {
                    if(res.code == 200){
                        layer.msg('验证码正确',{icon:1},function () {
                            /*parent.layer.closeAll("iframe");
                            parent.location.reload();*/
                            location.href="/sys/findpwd"
                        });
                    }else{
                        layer.msg(res.message,{icon:5});
                    }
                }
            })
            return false; //表单不提交，通过ajax的方式异步提交数据。
        })
    })





</script>
</html>